package com.yootk.task;

import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

import java.util.concurrent.TimeUnit;

/**
 * 异步线程任务处理类
 */
@Slf4j
@Component
public class YootkThreadTask {

    @Async  // 异步处理
    public void startTaskHandler() {
        log.info("【异步线程】开启，执行线程：{}", Thread.currentThread().getName());
        try {
            TimeUnit.SECONDS.sleep(5);  // 模拟延迟
        } catch (InterruptedException e) {}
        log.info("【异步线程】结束，执行线程：{}", Thread.currentThread().getName());
    }
}
